package com.auth.Sercurity.demo1;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hujian
 * @version 1.0
 * @description: 工厂
 * @date 2022/2/16 11:59
 */
@Component
public class UserTaskStrategyFactory {

    public static Map<String,UserTaskStrategy> userTaskStrategyHashMap=new HashMap<>();

    //获取策略
    public static UserTaskStrategy getUserTaskStrategy(String userName){
        return userTaskStrategyHashMap.get(userName);
    }

    public static void redisterUserRaskStrategy(String userName,UserTaskStrategy userTaskStrategy){
        if (StringUtils.isBlank(userName) || userTaskStrategy==null){
            return;
        }else {
            userTaskStrategyHashMap.put(userName,userTaskStrategy);
        }
    }
}
